package com.yazi.mxz.server.controller;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yazi.mxz.common.entity.beans.Member;
import com.yazi.mxz.common.service.MemberService;
import com.yazi.mxz.server.response.StatusResponse;

@Controller("emailController")
@RequestMapping("/email")
public class EmailController extends BaseController {
	private static Logger log = LoggerFactory.getLogger(EmailController.class);
	
	@Resource
	MemberService memberService;
	
	@RequestMapping("/update")
	@ResponseBody
	public StatusResponse update(@RequestBody Member member) {
		log.debug("客户端 -> 修改邮箱");
		StatusResponse res = new StatusResponse();
		try{
			memberService.update(getLoginMember(), member);
			res.setOkMessage("修改成功");
		} catch (Exception e) {
			log.debug("客户端 -> 修改邮箱时异常", e);
			res.setErrorMessage(e.getMessage());
		}
		
		return res;
	}
}
